package javaer.starter.model;

import com.google.common.collect.Lists;
import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;

import java.util.List;
import java.util.Objects;

/**
 * 依赖
 *
 * @author yangzhen
 * @date 2023/6/5 10:56
 * @since 1.0.0
 */
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class DependencyModel extends BaseModel {

    public static final String SQL_TEMPLATE = "insert into starter_dependency (type_id, category, dep_id, group_id, artifact_id, version, scope, optional, classifier, dep_type, gmt_create, gmt_modified) values ";

    public static final String SQL_NAME = "starter_dependency.sql";

    /**
     * 脚手架类型唯一标识
     */
    String typeId;
    /**
     * 类别
     */
    String category;
    /**
     * 依赖唯一标识
     */
    String depId;
    /**
     * 依赖坐标组
     */
    String groupId;
    /**
     * 依赖坐标
     */
    String artifactId;
    /**
     * 依赖版本
     */
    String version;
    /**
     * 指定所依赖的项目的作用域，它有多种类型，表示依赖的限制范围，包括 compile, runtime, provided, test, system 和 import。
     */
    String scope;
    /**
     * 标记该依赖是否是可选的，如果标记为 "true"，则不会强制使用该依赖项。
     */
    String optional;
    /**
     * classifier是指为了在同一个版本下为了区分不同的构建输出而存在的一种方式
     */
    String classifier;
    /**
     * 表示依赖的文件类型，默认为 jar。
     */
    String depType;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        DependencyModel that = (DependencyModel) o;
        return Objects.equals(typeId, that.typeId) && Objects.equals(depId, that.depId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(typeId, depId);
    }

    public String getTypeId() {
        return typeId;
    }

    public void setTypeId(String typeId) {
        this.typeId = typeId;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public String getDepId() {
        return depId;
    }

    public void setDepId(String depId) {
        this.depId = depId;
    }

    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public String getArtifactId() {
        return artifactId;
    }

    public void setArtifactId(String artifactId) {
        this.artifactId = artifactId;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getScope() {
        return scope;
    }

    public void setScope(String scope) {
        this.scope = scope;
    }

    public String getOptional() {
        return optional;
    }

    public void setOptional(String optional) {
        this.optional = optional;
    }

    public String getClassifier() {
        return classifier;
    }

    public void setClassifier(String classifier) {
        this.classifier = classifier;
    }

    public String getDepType() {
        return depType;
    }

    public void setDepType(String depType) {
        this.depType = depType;
    }

    @Override
    public List<Object> getSqlValues() {
        return Lists.newArrayList(
                this.typeId,
                this.category,
                this.depId,
                this.groupId,
                this.artifactId,
                this.version,
                this.scope,
                this.optional,
                this.classifier,
                this.depType,
                this.getGmtCreate(),
                this.getGmtModified()
        );
    }
}